package com.m4f.city.web.controller.api;

import java.security.Principal;
import java.util.logging.Logger;

import org.springframework.security.oauth2.provider.OAuth2Authentication;

import com.m4f.city.business.domain.InternalUser;
import com.m4f.city.exception.M4FApiException;
import com.m4f.city.web.controller.BaseController;
import com.m4f.gaeweb.exception.M4FException;

public class ApiBaseController extends BaseController {
	private static final Logger LOGGER = Logger.getLogger(ApiBaseController.class.getName());
		
	@Override
	protected InternalUser getInternalUser(Principal principal)	throws M4FApiException {
		if(!(principal instanceof OAuth2Authentication)) {
			throw new M4FApiException();
		}
		
		try {
			return super.getInternalUser(principal);
		} catch(M4FException e) {
			throw new M4FApiException();
		}
	}
}
